﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace WowGuildSite.Armory
{
    public enum BarType
    {
        Health,
        Mana,
        Energy,
        Rage,
    }

    public class ArmoryBar
    {
        private BarType type;
        private int     effective;

        public int      Effective
        {
            get { return effective; }
        }

        public BarType  Type
        {
            get { return type; }
        }

        internal static ArmoryBar FromElement(XmlElement element)
        {
            if (element == null)
            {
                return new ArmoryBar();
            }

            ArmoryBar bar = new ArmoryBar();
            bar.effective = ArmoryXmlUtility.GetElementAttributeInt(element, "effective");

            if (element.Name == "health")
            {
                bar.type = BarType.Health;
            }
            else
            {
                string barKey = ArmoryXmlUtility.GetElementAttributeText(element, "type");
                switch (barKey)
                {
                    case "r":
                        bar.type = BarType.Rage;
                        break;
                    case "e":
                        bar.type = BarType.Energy;
                        break;
                    case "m":
                        bar.type = BarType.Mana;
                        break;
                }
            }

            return bar;
        }

        private ArmoryBar()
        {}
    }
}
